package com.xxzuibang.day14.异常;

import java.util.Scanner;

public class Test01 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int num=0;
        String inputStr="";
        while (true) {
            System.out.println("请输入一个整数：");
            inputStr=sc.next();
            try {
                num=Integer.parseInt(inputStr);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个正确的整数！");
            }
        }
        System.out.println("你输入的值为"+num);


    }
}
